package com.xinheyun.demo.leetcode;

import java.util.ArrayDeque;
import java.util.Deque;
import org.springframework.web.servlet.mvc.method.annotation.ResponseBodyEmitter.DataWithMediaType;

/**
 * @description: TODO
 * @author: Sarah
 * @modified By: Sarah
 * @date: Created in 2021/8/8 19:16
 * @version:v1.0
 */
public class test2033 {

}

class MinStack {

    /**
     * initialize your data structure here.
     */

    Deque<Integer> stack;
    Deque<Integer> minStack;

    public MinStack() {
        stack = new ArrayDeque<>();
        minStack = new ArrayDeque<>();
        minStack.push(Integer.MIN_VALUE);
    }

    public void push(int x) {
        stack.push(x);
        if(x<minStack.getFirst()){
            minStack.push(x);
        }
    }

    public void pop() {
        Integer pop = stack.pop();
        if(pop==minStack.getFirst()){
            minStack.pop();
        }
    }

    public int top() {
        return stack.getFirst();
    }

    public int min() {
        return minStack.getFirst();

    }
}